package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.ProductOrderMapper;
import com.pojo.ProductOrder;
import com.service.ProductOrderService;
import com.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Date;
import java.util.List;

@Service
public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, ProductOrder> implements ProductOrderService {

    @Autowired
    private ProductOrderMapper productOrderMapper;

    @Override
    public void addProductOrder(ProductOrder productOrder) {
        String username = productOrder.getUsername();
        String str = username + "的订单|" + new Date();
        productOrder.setTitle(str);
        productOrderMapper.insert(productOrder);
    }

    @Override
    public List<ProductOrder> findAll(String username) {
        System.out.println("username:" + username);
        QueryWrapper<ProductOrder> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        wrapper.eq("status",0);
        List<ProductOrder> productOrders = productOrderMapper.selectList(wrapper);
        return productOrders;
    }
}
